package user

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method "GET"
        url("/api/users/username") {
            queryParameters {
                parameter("username", "zhang")
            }
        }
    }
    response {
        status 200
        body(
                """
                  {
                          "id": 1,
                          "username": "zhang",
                          "password": "12345678",
                          "email": "zhang@qq.com",
                          "mobilePhone": "12345678901",
                          "createDate": "2018-08-08"
                  }
            """
        )
        bodyMatchers {
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.username', byRegex(onlyAlphaUnicode()))
            jsonPath('$.password', byType())
            jsonPath('$.email', byRegex(email()))
            jsonPath('$.mobilePhone', byRegex(number()))
            jsonPath('$.createDate', byRegex(number()))
        }
        headers {
            header('Content-Type': 'application/json;charset=UTF-8')
        }
    }
}
